#!/usr/bin/python

from flask import Flask, jsonify, request
from src.invhnd import InvisibleHand

app = Flask("InvisibleHand")
invhnd = InvisibleHand()

@app.route('/api/v1.0/getPlugins', methods=['GET'])
def get_plugins():
    return jsonify(invhnd.get_plugins())

@app.route('/api/v1.0/getPluginItems/<int:id>', methods=['GET'])
def get_plugin_items(id):
    return jsonify(invhnd.get_plugin_items(id))

@app.route('/api/v1.0/doPluginAction/<int:id>', methods=['GET'])
def do_plugin_action(id):
    action = request.args.get('action')
    uinput = request.args.get('input')
    result = invhnd.do_plugin_action(id, action, uinput)
    return jsonify({'result' : result})

if __name__ == '__main__':
    app.run(debug=True, host="0.0.0.0", use_reloader=False)


